Getting Started¶
To get started with EchoFlow, you can install it from pip
by running:
pip install echoflow
In this tutorial, we’ll load the spiral dataset which is provided with the library.
[1]:
from echoflow.demo import load_spiral
df = load_spiral()
df.head()
[1]:
x | y | |
---|---|---|
0 | 0.080377 | 0.008525 |
1 | -0.001777 | 0.003350 |
2 | -0.002866 | 0.007323 |
3 | -0.107810 | 0.001931 |
4 | -0.099708 | 0.011197 |
This dataset contains two continuous columns which, when plotted, form a spiral.
[2]:
%matplotlib inline
import matplotlib.pyplot as plt
plt.figure(figsize=(6,6))
plt.scatter(df["x"], df["y"]);

We can then use the EchoFlow
class to model this dataset.
[3]:
from echoflow import EchoFlow
model = EchoFlow(nb_blocks=8)
model.fit(df)
Epoch 10 | Train Loss -0.230
Epoch 20 | Train Loss -0.225
Epoch 30 | Train Loss -0.280
Epoch 40 | Train Loss -0.345
Epoch 50 | Train Loss -0.399
Epoch 60 | Train Loss -0.434
Epoch 70 | Train Loss -0.408
Epoch 80 | Train Loss -0.438
Epoch 90 | Train Loss -0.460
Epoch 100 | Train Loss -0.513
Epoch 110 | Train Loss -0.599
Epoch 120 | Train Loss -0.532
Epoch 130 | Train Loss -0.522
Epoch 140 | Train Loss -0.518
Epoch 150 | Train Loss -0.548
Epoch 160 | Train Loss -0.578
Epoch 170 | Train Loss -0.489
Epoch 180 | Train Loss -0.582
Epoch 190 | Train Loss -0.571
Epoch 200 | Train Loss -0.544
Epoch 210 | Train Loss -0.538
Epoch 220 | Train Loss -0.527
Epoch 230 | Train Loss -0.589
Epoch 240 | Train Loss -0.528
Epoch 250 | Train Loss -0.616
Epoch 260 | Train Loss -0.535
Epoch 270 | Train Loss -0.524
Epoch 280 | Train Loss -0.558
Epoch 290 | Train Loss -0.528
Epoch 300 | Train Loss -0.509
Epoch 310 | Train Loss -0.539
Epoch 320 | Train Loss -0.563
Epoch 330 | Train Loss -0.555
Epoch 340 | Train Loss -0.571
Epoch 350 | Train Loss -0.553
Epoch 360 | Train Loss -0.514
Epoch 370 | Train Loss -0.561
Epoch 380 | Train Loss -0.543
Epoch 390 | Train Loss -0.509
Epoch 400 | Train Loss -0.525
Epoch 410 | Train Loss -0.526
Epoch 420 | Train Loss -0.574
Epoch 430 | Train Loss -0.555
Epoch 440 | Train Loss -0.516
Epoch 450 | Train Loss -0.547
Epoch 460 | Train Loss -0.546
Epoch 470 | Train Loss -0.569
Epoch 480 | Train Loss -0.515
Epoch 490 | Train Loss -0.532
Epoch 500 | Train Loss -0.523
Epoch 510 | Train Loss -0.564
Epoch 520 | Train Loss -0.518
Epoch 530 | Train Loss -0.539
Epoch 540 | Train Loss -0.533
Epoch 550 | Train Loss -0.509
Epoch 560 | Train Loss -0.552
Epoch 570 | Train Loss -0.565
Epoch 580 | Train Loss -0.515
Epoch 590 | Train Loss -0.510
Epoch 600 | Train Loss -0.515
Epoch 610 | Train Loss -0.546
Epoch 620 | Train Loss -0.524
Epoch 630 | Train Loss -0.596
Epoch 640 | Train Loss -0.578
Epoch 650 | Train Loss -0.459
Epoch 660 | Train Loss -0.505
Epoch 670 | Train Loss -0.553
Epoch 680 | Train Loss -0.540
Epoch 690 | Train Loss -0.545
Epoch 700 | Train Loss -0.581
Epoch 710 | Train Loss -0.582
Epoch 720 | Train Loss -0.531
Epoch 730 | Train Loss -0.540
Epoch 740 | Train Loss -0.516
Epoch 750 | Train Loss -0.521
Epoch 760 | Train Loss -0.562
Epoch 770 | Train Loss -0.528
Epoch 780 | Train Loss -0.580
Epoch 790 | Train Loss -0.535
Epoch 800 | Train Loss -0.546
Epoch 810 | Train Loss -0.554
Epoch 820 | Train Loss -0.509
Epoch 830 | Train Loss -0.507
Epoch 840 | Train Loss -0.494
Epoch 850 | Train Loss -0.536
Epoch 860 | Train Loss -0.558
Epoch 870 | Train Loss -0.547
Epoch 880 | Train Loss -0.552
Epoch 890 | Train Loss -0.554
Epoch 900 | Train Loss -0.561
Epoch 910 | Train Loss -0.541
Epoch 920 | Train Loss -0.520
Epoch 930 | Train Loss -0.564
Epoch 940 | Train Loss -0.492
Epoch 950 | Train Loss -0.542
Epoch 960 | Train Loss -0.562
Epoch 970 | Train Loss -0.579
Epoch 980 | Train Loss -0.503
Epoch 990 | Train Loss -0.541
Epoch 1000 | Train Loss -0.525
Once our model is trained, we can sample from it.
[4]:
synthetic = model.sample(num_samples=1000)
plt.scatter(synthetic["x"], synthetic["y"])
[4]:
<matplotlib.collections.PathCollection at 0x7fdac6646650>
